package com.fenghongzhang.day011picerview;

import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBarDrawerToggle;
import androidx.appcompat.app.AppCompatActivity;
import androidx.drawerlayout.widget.DrawerLayout;

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.widget.Toolbar;

public class Main3Activity extends AppCompatActivity {
    private DrawerLayout mDrawerLayout;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main3);

        mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);

        //mDrawerLayout与mToolbar关联起来
//        ActionBarDrawerToggle actionBarDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, toolbar, "kai", "guan");
        //初始化状态
//        actionBarDrawerToggle.syncState();

        //监听
        mDrawerLayout.addDrawerListener(new DrawerLayout.DrawerListener() {
            @Override
            public void onDrawerSlide(@NonNull View view, float v) {
                Log.i("---", "滑动中");
            }

            @Override
            public void onDrawerOpened(@NonNull View view) {
                Log.i("---", "打开");
            }

            @Override
            public void onDrawerClosed(@NonNull View view) {
                Log.i("---", "关闭");
            }

            @Override
            public void onDrawerStateChanged(int i) {
                Log.i("---", "状态改变");
            }
        });

    }

    @SuppressLint("WrongConstant")
    public void left(View view) {
        //打开左边
//        mDrawerLayout.openDrawer(Gravity.START);

//        打开右边
//        mDrawerLayout.openDrawer(Gravity.END);

        //关闭一边
//        mDrawerLayout.closeDrawer(Gravity.START);
        //关闭所有
//        mDrawerLayout.closeDrawers();

    }
}
